﻿using AutoMapper;
using B.S.BasicData.Domain;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Write.Api.Application.Command.W;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Write.Api.Controllers
{
    /// <summary>
    /// 货运单
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PendingShipmentWaybillsController : ControllerBase
    {
        /// <summary>
        ///中介者
        /// </summary>
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public PendingShipmentWaybillsController(IMediator mediator)
        {
            _mediator = mediator;
        }


        /// <summary>
        /// 添加货运单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        

        [HttpPost]
        public Task<ApiResult<int>> CreatePendingShipmentWaybills(CreatePendingShipmentWaybillsCommand request, CancellationToken cancellationToken)
        {
           return _mediator.Send(request);
        }


        /// <summary>
        /// 显示发货运单
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiPaging<PendingShipmentWaybillsModel>> ShowPendingShipmentWaybills([FromQuery]ShowPendingShipmentWaybillsCommand request, CancellationToken cancellationToken)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdatePendingShipmentWaybills(UpdatePendingShipmentWaybillsCommand request, CancellationToken cancellationToken)
        {
            return _mediator.Send(request);
        }

        /// <summary>
        /// 回显货运单
        /// </summary>
        /// <param name="request">查询id</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<PendingShipmentWaybillsModel>> FullPendingShipmentWaybills([FromQuery]FullPendingShipmentWaybillsCommand request, CancellationToken cancellationToken)
        {

            return _mediator.Send(request);
        }
    }
}
